package com.wang.tool.monitor.core;

import java.util.HashMap;
import java.util.Map;

/**
 * 性能指标
 *
 * @author shaopeng
 * @date 2022/9/9
 */
public enum PerformanceEnum {

    /**
     * 超时 timeout
     */
    TIMEOUT(2),

    /**
     * 慢 slow
     */
    SLOW(1),

    /**
     * 常规 normal
     */
    NORMAL(0);

    private static final Map<Integer, PerformanceEnum> CACHE = new HashMap<>();
    static {
        for (PerformanceEnum value : values()) {
            CACHE.put(value.code, value);
        }
    }


    /**
     * code
     */
    private final int code;

    PerformanceEnum(int code) {
        this.code = code;
    }

    public static PerformanceEnum getByCode(Integer code) {
        return code == null ? null : CACHE.get(code);
    }


    public int getCode() {
        return code;
    }
}
